Skip to main content

Postgres

Overview

Postgres is an open source SQL database. It supports array, JSONB, JSON, and vector data types and has several supporting query functions and query syntax extensions. Qarbine uses the Postgres node.js driver for interacting with the database.

Postgres Configuration Information

From your Postgres database you need to determine your endpoint information which includes

  • URL,
  • port number,
  • account name, and
  • account password.

Qarbine Configuration

Compute Node Preparation

Determine which compute node service endpoint you want to run this data access from. That URL will go into the Data Service’s Compute URL field. Its form is “https://domain:port/dispatch”. A sample is shown below.

  

The port number corresponds to a named service endpoint configured on the given target host. For example, the primary compute node usually is set to have a ‘main’ service. That service’s configuration is defined in the ˜./qarbine.service/config/service.main.json file. Inside that file the following driver entry is required when using the MySQL interaction.

"drivers" :[
. . .
"./driver/postgresDriver.js"
]

The relevant configuration file name for non primary (main) Qarbine compute nodes is service.NAME.json. Remember to have well formed JSON syntax or a startup error is likely to occur. If you end up adding that entry then restart the service via the general command line syntax

pm2 restart <service>

For example,

pm2 restart main

or simply

pm2 restart all

Data Service Definition

Open the Administration Tool.

Navigate to the Data Services tab.

  

A data service defines on what compute node a query will run by default along with the means to reach to target data. The latter includes which native driver to use along with settings corresponding to that driver. Multiple Data Sources can reference a single Data Service. The details of any one Data Service are thus maintained in one spot and not spread out all over the place in each Data Source. The latter is a maintenance and support nightmare.

To begin adding a data service click

  

On the right hand side enter a name and optionally a description.

  

Set the Compute URL field based on the identified compute node above. Its form is “https://domain:port/dispatch”. A sample is shown below.

  

Choose the driver and set the values as shown below.

  

Enter the values for the server template. Below are some examples for Cockroach and AWS RDS postgres.

  

  

Enter account information as shown below

  

Enter the database information into the field shown below.

  

You can reference environment variables using the syntax %NAME%. Any strings should be quoted and the key\value pairs separated by commas.

Using SSL Certificates

If you require certificate parameters then there are several options.

Development Only

If the server requires SLL and you are only testing then this additional parameter can be used.

ssl.rejectUnauthorized = false

Qarbine configContent

Use the following pattern which requires the files to be in the ˜/qarbine.service/config folder and the file names starting with "postgres".

ssl.rejectUnauthorized = true,
ssl.ca = "configContent:postgres-ca.crt",
ssl.key = "configContent:postgres-client.key",
ssl.cert = "configContent:postgres-client.crt",

Qarbine resourceContent

Use Qarbine resources and the pattern

ssl.rejectUnauthorized = true,
ssl.ca = "resourceContent:postgres-ca.crt",
ssl.key = "resourceContent:postgres-client.key",
ssl.cert = "resourceContent:postgres-client.crt",

The value after the colon is the Qarbine resource name. The service.NAME.json file must also have an entry in the supportResources:[] list for the resource name. Access to Qarbine’s resource management feature varies by edition and other factors.

Testing the Connection

Test your settings by clicking on the toolbar image highlighted below.

  

The result should be something similar to the following

  

Save the Data Service by clicking on the image highlighted below.

  

The data service will be known at the next log on time.

Tutorial Data

The data for the Qarbine tutorial can be found in

~/qarbine.service/sample/postgres/pgJsonStock.sql

It can be loaded into a test database and you can configure a Qarbine data service to access it per the instructions above.